/**
 * Arduino两轮小车
 * 
 * 本程序可不受限制的用于学习和教学，商业用途请联系作者。
 * 本程序不对用户因使用程序而造成任何形式的损失负责。
 * 
 * site: http://www.xpstem.com/maker/arduino-vehicle
 * author: billy zhang
 */
 
#include "LedController.h"

const uint8_t Head_Left_Led   = 0x00000001;
const uint8_t Head_Right_Led  = 0x00000010;
const uint8_t Stop_Left_Led   = 0x00000100;
const uint8_t Stop_Right_Led  = 0x00001000;
const uint8_t Turn_Left_Led   = 0x00010000;
const uint8_t Turn_Right_Led  = 0x00100000;

void LedController::control(bool head_led, bool stop_led, bool turnleft_led, bool turnright_led) 
{
   int val = 0x00;
   if ( head_led )
   {
     val += 0x11;
   }
   if ( stop_led )
   {
    val += (0x11 << 2);
   }
   if ( turnleft_led )
   {
     val += (1 << 5);
   }
   if ( turnright_led )
   {
     val += (1 << 6);
   }
   
   bus_.write(address_, val); 
}
    
LedController::~LedController()
{
  
}
